<template>
	<view class="main">
		<view class="head">
			<view class="top">
				<view class="top_left">
					 <image
							src="/static/img/logo.png"
							style="width:250rpx; height:80rpx"
					></image>
				</view>
			</view>
			<view class="swiper_box">
				<u-swiper
					:list="adslist"
					keyName="img"
					:autoplay="false"
					:interval="5000"
				></u-swiper>
			</view>
			<view class="tag_box">
				<text style="color: #43e4f8">按标签搜索：</text>
				<text v-for="(item,index) in label" :key="index" @click="setWelfare(item)">{{item}}</text>
			</view>
		</view>
		<view class="main_content">
			<view class="top_box">
				<view class="user_item" style="margin-top: -200rpx;">
					<view class="user_box"  @click="goto('/resume/details'+'?source=1')">
						<image src="/static/img/text.png" style="width:70rpx; height:70rpx"></image>
						<view class="user_row">我的简介</view>
						<text>个人简介描述</text>
					</view>
					<view class="user_box"  @click="goto('/resume/record')">
						<image src="@/static/img/jiaoyin.png" style="width:70rpx; height:70rpx"></image>
						<view class="user_row">邀请记录</view>
						<text>浏览/投递记录</text>
					</view>
				</view>
				
				<!-- <view class="user_item">
					<view class="user_box"  @click="goto('/resume/details')">
						<image src="@/static/img/qiye.png" style="width:70rpx; height:70rpx"></image>
						<view class="user_row">企业管理</view>
						<text>企业简介</text>
					</view>
					<view class="user_box"  @click="goto('/resume/details')">
						<image src="@/static/img/msg.png" style="width:70rpx; height:70rpx"></image>
						<view class="user_row">我的评价</view>
						<text>对企业的评价</text>
					</view>
				</view> -->
				
				<view class="user_item">
					<view class="user_box" @click="goto('/resume/money')">
						<image src="@/static/img/maozhua.png" style="width:70rpx; height:70rpx"></image>
						<view class="user_row">我的猫币</view>
						<text>提现</text>
					</view>
					<view class="user_box" @click="goto('/pages/setting/index')">
						<image src="@/static/img/lan_logo.png" style="width:150rpx; height:50rpx"></image>
						<view class="user_row">平台设置</view>
						<text>在线客服</text>
					</view>
				</view>
			</view>
			
			<swiper circular='true' style="height: 450rpx;background-color: black;" current='0' @change="swiperChange" indicator-active-color='red'>
				<swiper-item v-for="(item,i) in hotentlist" :key="i">
					<view class="intro_box">
						<view class="intro_left">
							<view class="myphoto">
								<image :lazy-load="true" style="width:180rpx; height:180rpx"  :src="imgURL + item.logo"></image>
							</view>
							<u-button class="myjob" @click="goto('/resume/entdetails?id='+item.ent_id+'&source=1')">查看企业</u-button>
						</view>
						<view class="intro_right">
							<view class="job_item">{{item.ent_name}}</view>
							<view class="intro_item">{{item.about || ""}}</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
			<view class="king_table">
				<text @click="operation(2)" :class="tableactive == 2 ? 'active' : 'inactive'">企业榜</text>
				<text @click="operation(1)" :class="tableactive == 1 ? 'active' : 'inactive'">秀英榜</text>
			</view>
			<view  v-if="tableactive == 1">
				<block v-for="(item,index) in userlist">
					<view class="company_box" @click="goto('/pages/enterprise/resumedetails?id='+item.uid+'&source=1')">
						<view style="flex: 1;width: 80rpx;height: 90rpx;margin-right:10rpx">
							<image style="max-width:100%;max-height:100%" src="@/static/img/renc.jpg"></image>
						</view>
						<view class="company_item_box">
							<view class="company_name">
								{{item.name || ""}} / {{item.age1 || 25}}岁
							</view>
							<view class="company_job">
								{{item.education || ""}} / {{item.skill || ""}}
							</view>
						</view>
						<view style="display: flex;flex: 1;align-items: center;">	
							<image style="max-width:50rpx;max-height:50rpx;" src="@/static/img/hot.png"></image>
							{{item.view || 10}}
						</view>
					</view>
				</block>
			</view>
			<view  v-else>
				<block v-for="(item,index) in entlist">
					<view class="company_box" @click="goto('/resume/entdetails?id='+item.ent_id+'&source=1')">
						<view style="flex: 1;width: 80rpx;height: 90rpx;margin-right:10rpx">
							<image style="max-width:100%;max-height:100%" src="@/static/img/qiye.jpg"></image>
						</view>
						<view class="company_item_box">
							<view class="company_name">
								{{item.ent_name || ""}}
							</view>
							<view class="company_addr">
								{{item.fieldname || ""}}
							</view>
						</view>
						<view style="display: flex;flex: 1;align-items: center;">	
							<image style="max-width:50rpx;max-height:50rpx;" src="@/static/img/hot.png"></image>
							{{item.view || 10}}
						</view>
					</view>
				</block>
			</view>
		</view>
		<Tabbar :count="0"></Tabbar>
	</view>
</template>

<script>
	import Tabbar from "@/components/Tabbar"
	import util from "@/utils/utils.js"
	import { getKingEntList,getKingResumeList } from '@/api/ranking.js'
	import { getAds,getHotEnt } from '@/api/index.js'
	import { imgURL } from '@/utils/config'
	export default {
		components: {
			Tabbar
		},
		data() {
			return {
				type:2,
				tableactive:2,
				label:['应届生','就职人才'],
				imgURL:imgURL,
				yaoqingModal:false,
				showposition:false,
				timeshow:false,
				entlist: [],
				userlist: [],
				adslist: [],
				hotentlist:[],
				form:{
					page:1,
					pagesize:10,
					total:0,
					keyword:'',
				},
				yaoqingform:{
					uid:'',
					position_id:'',
					position_name:'',
					interview_time:'',
					interview_date:''
				},
				positionList:[],
				defaultIndex:[[]]
			}
		},
		onLoad() {
			getAds().then(res=>{
				if(res.code == 200){
					this.adslist = res.data
				}
			});
			this.getHotEnt()
			this.getEntList()
		},
		onShow() {
			this.type = util.get('type')
			if(this.type == 2){
				uni.redirectTo({
					url: '/pages/enterprise/index'
				});
			}
		},
		onShareAppMessage(res) {
			return {
				title: "职酷肥猫",
				desc: "致力于企业岗职专属定位，大学生就业归属职涯规精度价值化为发展核心，促进企、校、人才零距离接触的公众平台",
				imageUrl: "/static/img/logo.png",
				path: '/resume/index',
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
				}
			}
		},
		onShareTimeline() {
			return {
				title: "职酷肥猫",
				desc: "致力于企业岗职专属定位，大学生就业归属职涯规精度价值化为发展核心，促进企、校、人才零距离接触的公众平台",
				imageUrl: "/static/img/logo.png",
				path: '/resume/index',
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(res) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
				}
			}
		},
		methods: {
			operation(tableactive){
				this.tableactive = tableactive
				if(tableactive == 1){
					this.getResume()
				}
				else{
					this.getEntList()
				}
			},
			
			//获取企业信息
			getEntList() {
				getKingEntList(this.form).then(res=>{
					if(res.code == 200){
						this.entlist = res.data
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			
			//获取热门企业
			getHotEnt(){
				getHotEnt().then(res=>{
					if(res.code == 200){
						this.hotentlist = res.data
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			
			//获取人才信息
			getResume() {
				getKingResumeList({}).then(res=>{
					if(res.code == 200){
						this.userlist = res.data
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			goto(tourl) {
				uni.navigateTo({
					url: tourl
				});
			}
		},
	}
</script>

<style lang="scss">
	@import "@/static/css/index.scss";
</style>